function buildWindow() {
    Ext.Ajax.timeout = 2000;    //设置超时时间 2020-08-05
    var now = new Date();
    //alert(orgName);
    var vroot = new Ext.tree.AsyncTreeNode({
        text: companyName,
        draggable: false,
        id: orgCode,
        expanded: true,
        leaf: false
    });

    var vloader = new Ext.tree.TreeLoader({url: "../../servlet/system/OrgTreeServlet", baseParams: {}});
    vloader.on('beforeload', function(loader, node) {
        loader.baseParams.id = node.id;
        loader.baseParams.token=token;
    });
    vloader.on('load', function( This, node, response) {
        var obj = Ext.decode(response.responseText);
        if(obj.success===false)
        {
               Ext.Msg.alert("系统提示",obj.msg); 
        }
    });
    

    var treeOrg = new Ext.tree.TreePanel({  
        title: '\u673a\u6784\u6811', //机构树
        id: 'OrganTree',
        useArrows: true,
        lines: true,
        autoScroll: true,
        animate: true,
        enableDD: false,
        containerScroll: true,
        width: 200,
        rootVisible: true,
        collapsed: true,
        collapsible: true,
        split: true,
        region: 'east',
        root: vroot,
        loader: vloader
    });

    treeOrg.on('click', function(node) {
        var token1 = new Date().getTime();
        Ext.Ajax.request({
            url: '../../servlet/system/OrgTreeClick',
            success: function(response, options) {
                window.frames["DataWindow"].location.reload();
                window.frames["Header"].location.reload();
            },
            params: {token:token,token1:token1,orgCode: node.id, leaf: node.leaf, orgName: node.text}
        });
    });

    var headerArea = new Ext.Panel({
        id: 'headerArea',
        //autoWidth:true,  
        height: 80,
        //frame:true,  
        region: 'north',
        html: '<iframe id="Header" name="Header" frameborder="0" width=100% height=100% scrolling="no" style="border:0px none;" src="header.jsp"></iframe>'
                //autoLoad:'header-2.html'
    });

    var menuArea = new Ext.Panel({
        title: '菜单栏',
        //renderTo:'con-div',
        width: 200,
        height: 350,
        //applyTo: 'con-div',
        // Displays one item at a time in a stacked layout.
        layout: 'accordion',
        collapsible: true,
        split: true,
        region: 'west'
    });


    var menuLoad = new Ext.tree.TreeLoader({url: "../../servlet/system/MenuTreeServlet", baseParams: {token:token}});
    menuLoad.on('beforeload', function(loader, node) {
        loader.baseParams.id = node.id;
        loader.baseParams.isManager=false;  //判断是否在管理页面上加载菜单
    });
    menuLoad.on('load', function( This, node, response) {
        var obj = Ext.decode(response.responseText);
        if(obj.success===false)
        {
               Ext.Msg.alert("系统提示",obj.msg); 
        }
    });
    
    var workArea = new Ext.Panel({
        //title:'主窗口',
        id: 'workArea',
        //frame:true,  
        region: 'center',
        html: '<iframe id="DataWindow" name="DataWindow" frameborder="0" width=100% height=100% scrolling="auto" style="border:0px none;" src="welcome.jsp"></iframe>'
    });
    var copyRightArea = new Ext.Panel({
        id: 'copyRightArea',
        //frame:true,  
        region: 'south',
        height: 10,
        html: '<iframe id="Footer" name="Footer" frameborder="0" width=100% height=100% scrolling="no" style="border:0px none;" src="footer.jsp"></iframe>'
                //autoLoad:'footer.jsp'                   
    });

    var applicationUI = new Ext.Viewport({
        layout: "border",
        items: [
            headerArea,
            menuArea,
            workArea,
            treeOrg,
            copyRightArea
        ]
    });

    function addSubMenuPanel(title, id, iconCls) {
        var menuRoot = new Ext.tree.AsyncTreeNode({
            text: title,
            draggable: false,
            id: id,
            expanded: true,
            leaf: false
        });
        var treeSubMenu = new Ext.tree.TreePanel({
            title: title, //机构树
            //id: 'MenuTree',
            iconCls: iconCls,
            useArrows: true,
            lines: true,
            autoScroll: true,
            animate: true,
            enableDD: false,
            containerScroll: true,
            width: 200,
            rootVisible: false,
            collapsed: false,
            collapsible: false,
            split: true,
            root: menuRoot,
            loader: menuLoad
        });
        menuArea.add(treeSubMenu);
    }

    var token1 = new Date().getTime();
    Ext.Ajax.request({
        url: '../../servlet/system/MenuLoad',
        success: function(response, options) {
            var obj = Ext.decode(response.responseText);
            //Ext.Msg.alert(obj.count);           
            for (var i = 0; i < obj.count; i++) {
                addSubMenuPanel(obj.data[i].name,obj.data[i].menuCode,obj.data[i].iconCls);
            }
            menuArea.doLayout();
        },
        failure: function(response, opts) {
            Ext.Msg.alert('系统提示','加载菜单错误: ' + response.status);
        },
        params: {id:'01',token:token,token1:token1}
    });
}

Ext.onReady(buildWindow);

